package cn.xiaoxiang.basic.dto;

import cn.xiaoxiang.basic.util.MD5Utils;
import cn.xiaoxiang.basic.util.StrUtils;
import cn.xiaoxiang.user.domain.User;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import java.util.Date;

@Data
public class BinderDto {
    @NotBlank(message = "手机号不能为空")
   private String phone;
    @NotBlank(message = "验证码不能为空")
   private String verifyCode;
    @NotBlank(message = "accessToken不能为空")
   private String accessToken;
    @NotBlank(message = "openId不能为空")
   private String openId;

    public User getUser(){
        String salt = StrUtils.getComplexRandomString(32);
        String passwords = MD5Utils.encrypByMd5(salt+"6");
        return User.builder()
                .username(this.phone)
                .email(this.phone)
                .salt(salt)
                .password(passwords)
                .state(1)
                .createtime(new Date())
                .build();
    }
}
